﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAL;

namespace WebService
{
    [System.Xml.Serialization.XmlInclude(typeof(ShortExpenseDataDislocation))]
    public class ShortExpenseDataDislocation : IShortExpenseData
    {
        public int distance;
        public String departure;
        public String arrival;

        public long date;
        public String description;
        public String justification;



        public override void SaveToDB(String ExpenseReport)
        {
            ExpenseLine l = new ExpenseLine();
            l.Date = new DateTime(date);
            l.Description = description;
            l.Justification = justification;
            l.ExpenseReportId = new Guid(ExpenseReport);
            l.Id = Guid.NewGuid();

            ExpenseLineDislocation d = new ExpenseLineDislocation();
            d.Distance = distance;
            d.Departure = departure;
            d.Arrival = arrival;
            d.Id = l.Id;

            //d.save(l);
            
            using(DataAccessDataContext dc = new DataAccessDataContext())
            {
                dc.ExpenseLines.InsertOnSubmit(l);
                dc.ExpenseLineDislocations.InsertOnSubmit(d);
                dc.SubmitChanges();
            }

        }
    }
}
